package com.atguigu.cloud.resp;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * ClassName: ResultData
 * Package: com.atguigu.cloud.resp
 * Description:
 *
 * @Author 加油-ssj
 * @Create 2025/3/13 15:45
 * @Version 1.0
 */
@Data
@Accessors(chain = true)
public class ResultData<T> {

    private String code;

    private String message;

    private  T data;

    private long timestamp;

    public ResultData() {
        this.timestamp=System.currentTimeMillis();
    }

    public static <T> ResultData<T> success(T data){

        ResultData<T> tResultData = new ResultData<>();
        tResultData.setCode(ReturnCodeEnum.RC200.getCode());
        tResultData.setMessage(ReturnCodeEnum.RC200.getMessage());
        tResultData.setData(data);
        return tResultData;
    }

    public static <T> ResultData<T> fail(String code,String message){

        ResultData<T> ResultData = new ResultData<>();
        ResultData.setCode(code);
        ResultData.setMessage(message);
  //      ResultData.setData(null);
        return ResultData;

    }
}
